<%--
  Created by IntelliJ IDEA.
  User: 70481
  Date: 2019/9/6
  Time: 11:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>医院就诊管理系统</title>
    <link href="${pageContext.request.contextPath}/layui/css/layui.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <style type="text/css">
        .layui-tab-item{height: 900px;}
    </style>
    <script type="text/javascript">
        //JavaScript代码区域
        layui.use('element', function(){
            var element = layui.element;

            element.on("collapse(department)",function (data) {
                alert(21324)
            })

        });

        function option(obj) {
            // 添加选项卡
            // alert(12)
            var element = layui.element;
            var title = $(obj).html();
            // if($("li[lay-id='"+params.title+"']").length == 0)
            if($("li[lay-id='"+title+"']").length === 0){
                // alert(title)
                if(title === "患者展示"){
                    element.tabAdd("myTab",{
                        title:title,
                        content:"<iframe src='${pageContext.request.contextPath}/patient.jsp' width='100%' height='100%'></iframe>",
                        id:title
                    })
                }
                if(title === "科室展示"){
                    element.tabAdd("myTab",{
                        title:title,
                        content:"<iframe src='${pageContext.request.contextPath}/department.jsp' width='100%' height='100%'></iframe>",
                        id:title
                    })
                }
                if(title==="采购信息"){
                    //采购信息的展示
                    element.tabAdd("myTab",{
                        title:title,
                        content:"<iframe src='${pageContext.request.contextPath}/drug.jsp' width='100%' height='100%'></iframe>",
                        id:title
                    })
                }
                if(title==="审核管理"){
                    // 审核信息的展示
                    element.tabAdd("myTab",{
                        title:title,
                        content:"<iframe src='${pageContext.request.contextPath}/exam.jsp' width='100%' height='100%'></iframe>",
                        id:title
                    })
                }

                if(title==="日志记录"){
                    element.tabAdd("myTab",{
                        title:title,
                        content:"<iframe src='${pageContext.request.contextPath}/log.jsp' width='100%' height='100%'></iframe>",
                        id:title
                    })
                }
            }
            element.tabChange("myTab", title);

        }
        // 变量
        var triageName = "";
        function triageManage(obj) {
            // 截取字符串
            triageName = $(obj).html().substring(0,4);
            // alert(triageName.substring(0,4))
            $.ajax({
                url:"${pageContext.request.contextPath}/selectRegisterDepartment",
                success:function(data){
                    $("#department").html("");
                    console.log(data[1].departmentId)
                    for(var i =0 ;i < data.length;i++){
                        $("#department").append("<dd><a href=\"javascript:void(0)\"  onclick='optionTriage("+data[i].departmentId+")'><span id = '"+data[i].departmentId+"' >"+data[i].departmentName+"</idspan></a></dd>")
                    }
                }
            })
        }

        function optionTriage(obj) {
            // 获取当前点击的元素的html
            // alert(obj)
            // 将obj以额外的参数的形式传递给下一个页面
            var element = layui.element;
            var title = triageName;
            // alert($("#"+obj+"").html())
            // alert( $("#triageIframe"))
            if($("li[lay-id='"+title+"']").length === 0){
                element.tabAdd("myTab",{
                    title:title,
                    content:"<iframe id='triageIframe' src='${pageContext.request.contextPath}/triage.jsp?departmentId="+obj+"' width='100%' height='100%'></iframe>",
                    id:title
                })
            }
            $("#triageIframe").prop("src","${pageContext.request.contextPath}/triage.jsp?departmentId="+obj)
            element.tabChange("myTab", title);
        }


    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 后台布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    ${sessionScope.user.userName}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">科室管理</a>
                    <dl class="layui-nav-child">

                        <dd><a href="javascript:void(0);" onclick="option(this)" >科室展示</a></dd>
<%--                        <dd><a href="javascript:;">列表二</a></dd>--%>
<%--                        <dd><a href="javascript:;">列表三</a></dd>--%>

<%--                        <dd><a href="">超链接</a></dd>--%>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">患者管理</a>
                    <dl class="layui-nav-child">
<%--                        <dd><a href="javascript:;">列表一</a></dd>--%>
                        <dd><a href="javascript:void(0);" onclick="option(this)">患者展示</a></dd>
<%--                        <dd><a href="">超链接</a></dd>--%>
                    </dl>
                </li>
                <li class="layui-nav-item" >
                    <a href="javascript:void(0);"  lay-filter = "department" onclick="triageManage(this)">分诊管理</a>
                    <dl class="layui-nav-child" id="department">

                    </dl>
                </li>


                <li class="layui-nav-item" >
                    <a href="javascript:void(0);"  lay-filter = "durp" onclick="triageManage(this)">药品管理</a>
                    <dl class="layui-nav-child" id="drug">
                        <dd><a href="javascript:void(0);" onclick="option(this)">采购信息</a></dd>
                        <dd><a href="javascript:void(0);" onclick="option(this)">审核管理</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item" >
                    <a href="javascript:void(0);"  lay-filter = "durp" onclick="triageManage(this)">日志管理</a>
                    <dl class="layui-nav-child" id="log">
                        <dd><a href="javascript:void(0);" onclick="option(this)">日志记录</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item"><a href="">其他</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
<%--            内容主体区域--%>

    <div class="layui-tab" lay-allowClose="true" lay-id="myTab" lay-filter="myTab">
        <ul class="layui-tab-title">

        </ul>
        <div class="layui-tab-content">

        </div>
    </div>

        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>

</body>
</html>
